<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <h1> Ajax Hello</h1>
<!--    fieldset给标签内的内容画一个框
    legend可以给fieldset一个标题
    -->
    <fieldset>
        <legend>Ajax 异步Get请求</legend>
    <button onclick="doAjaxGet01()">Ajax Get Request</button>
    <span id="result"> Data is Loading ...</span>
    </fieldset>
    <script>
        function doAjaxGet01(){
            debugger;
            // 1.创建XHR对象（XmlHttpRequst）-Ajax应用的入口对象
            var xhr = new XMLHttpRequest();
            // 2.在XHR
            xhr.onreadystatechange=function(){
                if(xhr.readyState==4 && xhr.status==200){
                        console.log(xhr.responseText);
                    document.getElementById("result").innerHTML=xhr.responseText;
                }
            }
            xhr.open("POST","http://localhost/doAjaxGet01",true);
            xhr.send(null);
        }
    </script>
</body>
</html>